package com.hui.wanxin.web.controller;


import com.hui.wanxin.web.entity.Menu;
import com.hui.wanxin.web.entity.PopularScience;
import com.hui.wanxin.web.service.MenuService;
import com.hui.wanxin.web.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 灰灰
 * @since 2023-10-13
 */
@RestController
@RequestMapping("/web/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @PostMapping("/add")
    public R add(@RequestBody Menu menu){
        return R.toAjax(menuService.save(menu));
    }
    @PostMapping("/list")
    public R list(@RequestBody Menu menu){
        return R.success(menuService.listByPage(menu));
    }
    @PutMapping()
    public R update(Menu menu){
        return R.toAjax(menuService.updateById(menu));
    }

    @PostMapping("/deleteByIds/{ids}")
    public R deleteByIds(@PathVariable(value = "ids") List<Integer> ids){
        return R.toAjax(menuService.removeByIds(ids));
    }
}

